package pdfsetter.ui;

import java.io.File;

/**
 * This command is responsible for retrieving output path for saving document.
 * 
 * @author Andrzej Dorobisz
 */
public class OutCommand implements PartCommand {
    private String[] args;
    private boolean initialized;

    public OutCommand() {
        this.initialized = false;
    }

    @Override
    public String getName() {
        return "-out";
    }

    @Override
    public void printUsage(String indent) {
        System.out.println(indent + "-out outputFile");
    }

    @Override
    public boolean setArgs(String[] args) {
        if ((args == null) || (args.length != 1) || (args[0] == null))
            return false;
        this.args = args;
        initialized = true;
        return true;
    }

    @Override
    public boolean isInitialized() {
        return initialized;
    }

    @Override
    public File process() throws ProcessCommandException {
        return new File(args[0]);
    }
}
